package com.lcf.app.rabbitmq.provider.config;

import com.lcf.common.model.MqConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ChenFei
 * @date 2021/12/2
 */
@Configuration
public class RabbitTopicConfig {

    //声明队列
    @Bean
    public Queue topicQueue() {
        return QueueBuilder.durable(MqConstant.TOPIC_QUEUE).build();
    }

    //声明交换机
    @Bean
    public TopicExchange topicExchange() {
        return ExchangeBuilder.topicExchange(MqConstant.TOPIC_EXCHANGE).build();
    }

    //绑定交换机和队列
    @Bean
    public Binding bindingTopicOne() {
        return BindingBuilder.bind(topicQueue()).to(topicExchange()).with(MqConstant.TOPIC_CAT_KEY);//cat.*
    }

    //绑定交换机和队列
    @Bean
    public Binding bindingTopicTwo() {
        return BindingBuilder.bind(topicQueue()).to(topicExchange()).with(MqConstant.TOPIC_DOG_KEY);//doc.*
    }

}
